package data;

import org.apache.commons.lang3.ArrayUtils;

public class Auth extends Data {

	private String name, password;
	public Auth(String name, String password) {
		this.name=name;
		this.password=password;
		data = (name+'\0'+password+'\0').getBytes();
	}

	@Override
	public byte[] getDataWithHeader() {
		short len = (short)(name.length()+password.length()+3+2);
		byte[] header = new byte[3];
		
		header[0] = (byte)len;
		header[1] = (byte)(len >> 8);
		header[2] = Data.AUTH;
		//Concatenate data
		byte[] bytes = ArrayUtils.addAll(header, data);
		return bytes;
	}

	@Override
	protected void process(short len) {
		// TODO Auto-generated method stub
		//Do nothing
	}
	

}
